package com.mystudy.leetcode.problem.tree.p_559;

import com.mystudy.leetcode.base.Node;

import java.util.List;

/**
 * @program: infoalgorithm
 * @description: N叉树的最大深度
 * @author: zhouzhilong
 * @create: 2019-07-23 17:18
 **/
public class Solution {

    /**
     * 递归算法
     * @param root
     * @return
     */
    public int maxDepth(Node root) {
        if(root == null){
            return 0;
        }
        int max = 0;
        List<Node> childrens =  root.children;
        for (int i = 0; i < childrens.size() ; i++) {
            Node cur = childrens.get(i);
            max = Math.max(max,maxDepth(cur));
        }

        return max+1;
    }
}
